<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<% //cookie检查
	String currUser = (String) session.getAttribute("user1");
	String userorbit = (String) session.getAttribute("userorbit"); //用户权限
	String md5oper = null;
	if (currUser != null){ //处于登录状态 
		response.sendRedirect("index.jsp");//重定向到登录页
		return;
	}else {	//
        Cookie c[]=request.getCookies();
        if(c!=null){   
        for(int i=0;i<c.length;i++) {            
            if("userinfo".equals(c[i].getName())) {               
                //Cookie中有用户名密码，保存,结构：用户名+md5算子+密码,暂时保存在username中
                currUser=c[i].getValue();
           }
            if("loginoper".equals(c[i].getName())) {	//设置md5算子，由cookie保存上次登录成功是的
            	md5oper = c[i].getValue();
            }
            
        }
        }
        if(currUser != null && md5oper != null){
        	String[] a = currUser.split(md5oper);
        	if(a.length==2){//Cookie中有用户名密码，保存,结构：用户名+md5算子+密码,暂时保存在username中
				request.getSession().setAttribute("user1", a[0]);
				request.getSession().setAttribute("userorbit", a[1]);
				response.sendRedirect("index.jsp");//重定向到登录页
				return;
        	}
        }
		
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cn" lang="cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>
      登 陆——DUSC学生管理系统
    </title>
    <link type="text/css" href="css/Smoothness-custom/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.7.1.js">
    </script>
    <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js">
    </script>
    <script type="text/javascript" src="js/md5-min.js">
    </script>
    <script src="js/jquery.zz.js" type="text/javascript">
    </script>
    <script type="text/javascript" src="js/login.js">
    </script>
    <style type="text/css">
      /*demo page css*/ 
      body{ 
      font: 75% "Trebuchet MS";
      margin:0px;
      background-color:#222222
      } 
      input.text {
      margin-bottom:12px; 
      width:95%; padding: .4em; 
      } 
      input { 
      display:block; 
      margin-left:20px;
      margin-top:5px;
      } 
      fieldset
      { padding:0; 
      border:0; 
      margin-top:10px; 
      }
    </style>
  </head>
  <body>


  </body>
</html>
